package com.funwell.server.config;

import cn.jiguang.common.ClientConfig;
import cn.jpush.api.JPushClient;
import com.ace.cache.utils.PropertiesLoaderUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

@Configuration
public class JPushConfig {

    private String appkey;

    private String masterSecret;


    public JPushConfig(){

    }

    @PostConstruct
    public void init() {
        PropertiesLoaderUtils prop = new PropertiesLoaderUtils(new String[]{"application.properties"});
        this.appkey = prop.getProperty("jpush.appKey");
        this.masterSecret=prop.getProperty("jpush.masterSecret");
    }

    @Bean
    public JPushClient jPushClient(){
        String key=this.appkey;
        String secret=this.masterSecret;
        return new JPushClient(secret, key, null, ClientConfig.getInstance());
    }


}
